/*
 * @Author: C.
 * @Date: 2021-09-01 15:06:52
 * @LastEditTime: 2021-09-07 09:58:48
 * @Description: file content
 */
import { defineStore } from 'pinia';
import { store } from '/@/store';
import { FieldInfo, PrintTemplate } from '/@/views/print/src/types';
import { printTemConstructor, FieldConstructor } from '/@/views/print/src/utils';
import { paperMap } from '/@/views/print/src/maps';
// import { router } from '/@/router';
interface usePrint {
  currentNode: FieldInfo;
  printTemplate: PrintTemplate;
  toggle: string[];
}

// 管理用户信息的vuex库
export const usePrintStore = defineStore({
  id: 'app-print',
  state: (): usePrint => ({
    currentNode: FieldConstructor({ role: 'label', label: '无' }),
    printTemplate: printTemConstructor(),
    toggle: ['2'],
  }),
  getters: {},
  actions: {
    setCurrentNode(node: FieldInfo) {
      this.currentNode = node;
    },
    setToggle(activeKey: string[]) {
      console.log(activeKey);

      this.toggle = activeKey;
    },
  },
});

// Need to be used outside the setup
export function usePrintStoreWithOut() {
  return usePrintStore(store);
}
